package payroll.trans;

import java.util.LinkedHashMap;
import java.util.Map;

import payroll.Employee;
import payroll.Paycheck;
import payroll.PayrollDatabase;

public class PaydayTransaction implements Transaction {

    private Map<Integer, Paycheck> paychecks = new LinkedHashMap<>();
    @Override
    public void execute() {

        //为每个雇员支付薪金
        for (Employee e : PayrollDatabase.listAllEmployees()) {
        //创建一个Paycheck
        Paycheck paycheck = new Paycheck();
        //计算工资并填写支付方式到Paycheck
        e.pay(paycheck);//根据计算工资方式，支付方式，填写paycheck
        //保存Paycheck
        paychecks.put(e.getEmpId(), paycheck);
        
    }
    }
    public Paycheck getPaycheckOf(int empId) {

        return paychecks.get(empId);
       
    }

}
